import { createI18n } from 'vue-i18n'
import el_zh_cn from 'element-plus/lib/locale/lang/zh-cn'
import el_en from 'element-plus/lib/locale/lang/en'

import zh_cn from './lang/zh-cn'
import en from './lang/en'

import projectSetting from '@/settings/projectSetting'
import sysCache from '@/utils/cache'

const messages = {
  'zh-CN': {
    el: el_zh_cn,
    ...zh_cn
  },
  'en-US': {
    el: el_en,
    ...en
  }
}

// 通过选项创建 VueI18n 实例
const i18n = createI18n({
  locale: sysCache.localCache.getCache('APP_LANG') || projectSetting.LANG,
  fallbackLocale: 'zh-CN',
  globalInjection: true,
  messages
})

export default i18n
